part of '../repository.dart';

const _kWebSavedPaymentMethodInfoUserIdKey = 'user_id';
const _kWebSavedPaymentMethodInfoSavedPaymentMethodIdsKey = 'saved_payment_method_ids';

class _WebSavedPaymentMethodInfoDto extends Equatable {
  const _WebSavedPaymentMethodInfoDto({
    required this.userId,
    required this.savedPaymentMethodIds,
  });

  final String userId;
  final BuiltList<String> savedPaymentMethodIds;

  @override
  List<Object?> get props {
    return [
      userId,
      savedPaymentMethodIds,
    ];
  }

  factory _WebSavedPaymentMethodInfoDto.fromJson(Map<String, dynamic> json) {
    final savedPaymentMethodIdData =
        json[_kWebSavedPaymentMethodInfoSavedPaymentMethodIdsKey] as List;
    final savedPaymentMethodIds = List.castFrom<dynamic, String>(savedPaymentMethodIdData);

    return _WebSavedPaymentMethodInfoDto(
      userId: json[_kWebSavedPaymentMethodInfoUserIdKey],
      savedPaymentMethodIds: savedPaymentMethodIds.toBuiltList(),
    );
  }

  Map<String, dynamic> toJson() {
    return {
      _kWebSavedPaymentMethodInfoUserIdKey: userId,
      _kWebSavedPaymentMethodInfoSavedPaymentMethodIdsKey: savedPaymentMethodIds.toList(),
    };
  }

  _WebSavedPaymentMethodInfoDto copyWith({
    String Function()? userId,
    BuiltList<String> Function()? savedPaymentMethodIds,
  }) {
    return _WebSavedPaymentMethodInfoDto(
      userId: userId == null ? this.userId : userId(),
      savedPaymentMethodIds:
          savedPaymentMethodIds == null ? this.savedPaymentMethodIds : savedPaymentMethodIds(),
    );
  }
}
